/***************************************************
> Copyright (C) 2024 ==KINGYI== All rights reserved.
> File Name: main.c
> Author:MOKI
> Mail:1913964829@qq.com
> Created Time: 2024年09月09日 星期一 09时13分09秒
***************************************************/
#include "global.h"

int main(int argc, const char *argv[])
{

    int id_flag;
    char ch;
    EnvironmentData envirdata;
    envirdata = randEnvirData();
    FILE *fp = fopen(ENVIRONMENT_DATA_FILE_PATH, "a");
    fwrite(&envirdata, sizeof(EnvironmentData), 1, fp);
    fclose(fp);
    fp = NULL;
    printf("***************************************\n");
    printf("欢迎使用智慧园林管理系统！\n");
    printf("今日园内环境温度:%d\t湿度:%d\t光照:%d\t空气质量:%d\n",
           envirdata.temperature, envirdata.humidity, envirdata.light, envirdata.air_quality);
    while (1)
    {
        printf("***************************************\n");
        printf("请选择您的身份：\n1.管理员\n2.员工\n3.游客\n");
        scanf("%d", &id_flag); // 获取身份id
        if (id_flag == 1)
        {
            isLogReg(id_flag);
        }
        else if (id_flag == 2)
        {
            isLogReg(id_flag);
        }
        else if (id_flag == 3)
        {
            isLogReg(id_flag);
        }
        else
        {
            printf("输入有误，请重新输入");
            continue;
        }
        printf("***************************************\n");
        printf("是否退出？(y/n)");
        setbuf(stdin, NULL); // 清除缓存区
        ch = getchar();
        if (ch == 'y')
        {
            break;
        }
    }
    return 0;
}
